package com.itheima.common;

/*
基于threadlocal的封装工具类，用户保存和获取当前登录用户的id
 */
public class BaseContext {
    //公共类且是private static 不存在内存泄露
    //存取多个泛型就用map
    private static ThreadLocal<Long> threadLocal=new ThreadLocal<>();

    //设值，绑定到当前线程
    public static void setCurrentId(Long id){
        threadLocal.set(id);
    }
    //获取值
    public static Long getCurrentId(){
        return threadLocal.get();
    }
}
